//
//  YKAudioPlayer.h
//  YK_BaseTools
//
//  Created by edward on 2018/11/27.
//

#import <Foundation/Foundation.h>
#import <CoreMedia/CMTime.h>

typedef enum : NSUInteger { // 顺序不要改
    YKCellVoicePlayStatusNeverPlaying, // 还没播放过
    YKCellVoicePlayStatusPlaying, // 正在播放中
    YKCellVoicePlayStatusPause, // 暂停
    YKCellVoicePlayStatusFinish, // 播放结束了
} YKCellVoicePlayStatus;

@class YKCommonStrategyData,YKAudioPlayer;

@protocol YKAudioManagerConflictProtocol <NSObject>

- (BOOL)audio:(YKAudioPlayer *_Nonnull)player handleConflictIfNeed:(void(^_Nonnull)(BOOL complete))complete;

@end


NS_ASSUME_NONNULL_BEGIN

static NSString *kTimerNotificationName = @"LMCellTimerNotification";
static NSString *kPlayErrorNotificationName = @"LMPlayErrorNotificationName";

@interface YKAudioPlayer : NSObject

+ (instancetype)sharedInstance;

@property (nonatomic,assign,readonly) CGFloat progress;
@property (nonatomic,copy,readonly) NSString *restTime;
@property (nonatomic,copy,readonly) NSString *total;
@property (nonatomic,copy,readonly) NSString *playingId;
//@property (nonatomic,strong,readonly) RACSubject<RACTuple *> *statusChangeSubject;

/** 定时器启动开始 经过的时间 */
@property (nonatomic, assign,readonly) NSInteger currentDuration;

/** 提示用 注意置空 */
@property (nonatomic, copy, nullable) void(^hintBlock)(NSString *msg);

/** 音频冲突代理 */
@property (nonatomic, weak) id<YKAudioManagerConflictProtocol> conflictDelegate;

/** 帖子的id不是唯一的 只有type拼接上id才是唯一的 但是这里只处理type为11的数据 所以只要传Id就行了 */
/** 这个方法初始化所有的播放状态为0 */
- (void)registerPlayStatusWithId:(NSString *)Id audioUrl:(NSString *)audio;

/** 标记正在播放音频的ID */
- (void)markPlayingId:(NSString *)Id;
/** 标记正在播放音频的ID 重复点击直接停止 */
- (void)markPlayingId:(NSString *)Id pauseToStop:(BOOL)pauseToStop;

/** 标记播放结束音频的ID 会停止当前音频的播放，跟你调用endplay是同个样 */
- (void)markStopPlayingId:(NSString *)Id;

/** 返回播放状态 */
- (YKCellVoicePlayStatus)playStatusWithId:(NSString *)Id;

/** 滑动到指定时间 */
- (void)seekToTime:(CMTime)time Id:(NSString *)Id;

/** 结束播放 */
- (void)endPlay;

/** 暂停播放 */
- (void)pausePlay;

/** 恢复播放 */
- (void)resumePlay;

@end

NS_ASSUME_NONNULL_END
